import IResponse from "@/services/response.service";
import { Injectable } from "@nestjs/common";
import axios from "axios";
import * as mockjs from "mockjs"

@Injectable()
export class NextService {

  getUserProfile(id: string) {
    return IResponse.success({
      id,
      name: mockjs.Random.cname(),
      county: mockjs.Random.county(true),
      city: mockjs.Random.city(),
      // avatar: mockjs.Random.image("100x100", "#4A7BF7"),
    })
  }
  login() {
    return IResponse.success({
      time: Date.now()
    })
  }

  getLiveLink() {
    const appid = "wx48123a3ae14d8588"
    const secret = "7980e2e7e046621c9d919096eb8109f2"
    const access_token = "83_CzYN0WMFNScdd9gopvfEFc-8gzZQmf_2YnPY0_gKQFr7DlV3aro54TFq64R2l0RN6ST74IFuoQEdEGDD4qbNEd5CvTt83krvRyPzjrIys2Jp-xusjOMduC2bgBsJJHjABABBZ"
    // return axios.get(`https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${appid}&secret=${secret}`).then(
    //   d => d.data
    // )
    return axios.post(`https://api.weixin.qq.com/wxa/generate_urllink?access_token=${access_token}`, {
      path: "/pks/stream/prepare/prepare",
      env_version: "develop",
      query: `scene=${encodeURIComponent(`room=4831&uid=247366`)}`
    }).then(d => d.data)
  }
}